package com.king01.controller;

import com.king01.entity.Branch_goods;
import com.king01.service.Branch_goodsService;
import com.king01.vo.AddBranchDoodsVo;
import com.king01.vo.BranchVo;
import com.king01.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：lqs
 * @date ：Created in 2023/9/27 14:59
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/Bg")
public class Branch_goodsController {

    @Autowired
    private Branch_goodsService branch_goodsService;


    @RequestMapping("/info")
    public Result info(@RequestBody List<Branch_goods> list) {
        Boolean aBoolean = branch_goodsService.selectById(list);
        if (aBoolean){
            return new Result(500,"存在重复",null);
        }
        Result result = branch_goodsService.addGoods(list);
        return result;
    }

    @RequestMapping("/addGoods")
    public Result addGoods(Integer currentPage, Integer pageSize){
        Result result = branch_goodsService.selectByNewAdd(currentPage, pageSize);
        return result;
    }

    @RequestMapping("/addGoodsUp")
    public Result addGoodsUp(@RequestBody List<AddBranchDoodsVo> addBranchDoodsVo){
        Result result = branch_goodsService.addBranchGoods(addBranchDoodsVo);
        return result;
    }

    @RequestMapping("/selectAll")
    public Result selectAll(Integer id){
        Result result = branch_goodsService.selectAll(id);
        return result;
    }

    @RequestMapping("/updateAll")
    public Result updateAll(Integer id){
        Result result = branch_goodsService.selectAll2(id);
        return result;
    }

    @RequestMapping("/addmain")
    public Result addmain(Integer currentPage, Integer pageSize,@RequestBody BranchVo branchVo){
        Result result = branch_goodsService.addOutLibrary(currentPage,pageSize,branchVo);
        return result;
    }

}

